#ifndef _SPI_ADC_H
#define _SPI_ADC_H

#include <mqueue.h>
#include <pthread.h>
#include <semaphore.h>
#include "ti_drivers_config.h"
#include "SysParaConfig.h"
//#define MAX_ADC_CHANNEL     3

#define ADCSAMPLESIZE              (512)
#define MAX_QUEUED_ADC_CONVERSIONS (5)

#define QUEUED_ADC_MESSAGE_SIZE    (sizeof(uint16_t) * ADCSAMPLESIZE)

#define ADCSens 0.0000381475547f

extern mqd_t queueReceive;

extern sem_t exitSavetask;//结束SRAM存储信号

typedef enum
{
    FEATURE_MODE = 0,
    MEDIUM_MODE,
    HIGH_MODE,
    OVERLENGTH_MODE
} SamplingMode;

typedef struct
{
    uint32_t count;
    uint16_t Index;
    uint16_t ADCBuffer[ADCSAMPLESIZE];
} ADCSample;

typedef struct{
    float rms;
    float avg;
    float vpp;
    float max;
    float min;
    float speed;
    float displance;
}ChannelEigenvalue;

/*typedef struct{
    ChannelEigenvalue SensorEigenvalue[MAX_ADC_CHANNEL];
    float Template;
    float Bat;
}SensorsEigenvalue;
extern SensorsEigenvalue st_SensorsEigenvalue;*/

extern sem_t SampleEndSem;

extern void SPIADC_ThreadStart(uint8_t mode);

#define ADC_ACCSENSORNUM 6
#define ADC_SAMPLE_COUNT (2000)

typedef struct{
    uint16_t adcvalue[ADC_ACCSENSORNUM][ADC_SAMPLE_COUNT];
    float Template;//温度
    uint16_t Bat;//电池电量
} Internal_adc_data;
extern Internal_adc_data internal_adc_data;

extern void samplesem_init(void);

#endif
